package com.yuneec.fly.fragments;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yuneec.fly.utils.inject.ViewUtils;

/**
 * Created by lk.sun on 6/2/2016.
 */
public abstract class BaseFragment extends Fragment {
    protected View selfView;
    protected boolean fragmentRunning;

    @Override
    public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        selfView = inflater.inflate(getContentViewResourceId(), container, false);
        ViewUtils.inject(this, selfView); //注入view和事件
        init(inflater, container, savedInstanceState);
        return selfView;
    }

    protected void init(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    }

    protected abstract int getContentViewResourceId();

    @Override
    public void onStart() {
        super.onStart();
        fragmentRunning = true;
    }

    @Override
    public void onStop() {
        super.onStop();
        fragmentRunning = false;
    }
}
